import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    count: 0,
    name: '博为峰',
    bwf: 'atstudy'
  },
  getters: {
    mul(state) {
      return state.count * 2;
    }
  },
  mutations: {
    jiaM(state, val) {
      // state.count++;
      state.count += val;
    },
    jianM(state, val) {
      // state.count--;
      state.count -= val;
    },
    upCaseM(state) {
      state.bwf = state.bwf.toUpperCase();
    }
  },
  actions: {
    jiaA(content, val) { //上下文
      content.commit('jiaM', val);
    },
    upCaseA(content) {
      content.commit('upCaseM')
    }
  },
  modules: {}
})
